import request from '@/utils/request'

// 获取轮播图列表
export function listBanner(query) {
  console.log(query)
  return request({
    url: '/mall/banner',
    method: 'get',
    params: query
  })
}

// 获取轮播图详情
export function getAotationChart(id) {
  return request({
    url: '/mall/banner/'+id,
    method: 'get',
  })
}

// 新增轮播图
export function addBanner(data) {
  return request({
    url: '/mall/banner',
    method: 'post',
    data: data
  })
}

// 修改轮播图
export function updateBanner(data) {
  return request({
    url: '/mall/banner',
    method: 'put',
    data: data
  })
}

// 单个删除轮播图
export function delAotationChart(id) {
  // console.log(id);
  return request({
    url: '/mall/banner/'+id,
    method: 'delete',
  })
}
// 批量删除轮播图
export function delAotationChartAll(ids) {
  // console.log(id);
  return request({
    url: '/mall/banner/'+ids,
    method: 'delete',
  })
}
//修改轮播图启用状态
export function handleEnabledChange(id, enabled){
  const data = {
    enabled
  }
  return request({
    url: '/mall/banner/' + id + '/enabled',
    method: 'put',
    data: data
  })
}
//修改轮播图时间
export function handleTimeChange(id, startTime, endTime){
  const data = {
    startTime: startTime,
    endTime: endTime
  }
  return request({
    url: '/mall/banner/' + id + '/time',
    method: 'put',
    data: data
  })
}

//修改轮播图图片
export function handleImageChange(id, data){
  return request({
    url: '/mall/banner/' + id + '/image',
    method: 'put',
    data: data
  })
}
